<?php

$htmlOutput = array();
$htmlOutput[] = '<div class="users index">';
$htmlOutput[] = sprintf('<h2>%s</h2>', __('Users', true));
$htmlOutput[] = '<p>';
$htmlOutput[] = $paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)));
$htmlOutput[] = '</p>';
$htmlOutput[] = '<table cellpadding="0" cellspacing="0">';
$htmlOutput[] = '   <tr>';
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('id'));
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('username'));
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('password'));
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('created'));
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('modified'));
$htmlOutput[] = sprintf('<th>%s</th>', $paginator->sort('group_id'));
$htmlOutput[] = sprintf('<th class="actions">%s</th>', __('Actions', true));
$htmlOutput[] = '   </tr>';
$i = 0;
foreach ($users as $user) {
    $class = null;
    if ($i++ % 2 == 0) {
        $class = ' class="altrow"';
    }
    $htmlOutput[] = sprintf('<tr %s>', $class);
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $user['User']['id'];
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $user['User']['username'];
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $user['User']['password'];
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $user['User']['created'];
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $user['User']['modified'];
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td>';
    $htmlOutput[] =             $html->link($user['Group']['name'], array('controller'=> 'groups', 'action'=>'view', $user['Group']['id']));
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '		 <td class="actions">';
    $htmlOutput[] =             $html->link(__('View', true), array('action'=>'view', $user['User']['id']));
    $htmlOutput[] =             $html->link(__('Edit', true), array('action'=>'edit', $user['User']['id']));
    $htmlOutput[] =             $html->link(__('Delete', true), array('action'=>'delete', $user['User']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $user['User']['id']));
    $htmlOutput[] = '		 </td>';
    $htmlOutput[] = '	  </tr>';
}
$htmlOutput[] = '   </table>';
$htmlOutput[] = '</div>';
$htmlOutput[] = '<div class="paging">';
$htmlOutput[] = $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
$htmlOutput[] = ' | ';
$htmlOutput[] =     $paginator->numbers();
$htmlOutput[] =     $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
$htmlOutput[] = '</div>';

$htmlOutput[] = '<div class="actions">';
$htmlOutput[] = '	<ul>';
$htmlOutput[] = sprintf('<li>%s</li>', $html->link(__('New User', true), array('action'=>'add')));
$htmlOutput[] = '	</ul>';
$htmlOutput[] = '</div>';

echo implode("\n", $htmlOutput);

?>
